Applications:
/* Name : Main.c * Purpose : Source code for SEGMENT Interfacing with ATMEGA16. * Author : GEMICATES * Date : 10-07-2017 * Website : www.gemicates.org * Revision : None */ #include <avr/io.h> // Header File for ATMEGA16 #include <util/delay.h> // Include Delay Function void main() { DDRD=0xff; // To Set PORT D as Output Port while (1) // Infinte loop { // Turn ON Each Segment in the Order Of A-H PORTD = 0xFE; // 'A' segment turn on _delay_ms(500); PORTD = 0xFD; // 'B' segment turn on _delay_ms(500); PORTD = 0xFB; // 'C' segment turn on _delay_ms(500); PORTD = 0xF7; // 'D' segment turn on _delay_ms(500); PORTD = 0xEF; // 'E' segment turn on _delay_ms(500); PORTD = 0xDF; // 'F' segment turn on _delay_ms(500); PORTD = 0xBF; // 'G' segment turn on _delay_ms(500); PORTD = 0x7F; // 'H' segment turn on _delay_ms(500); // Default 'H' segment turn ON PORTD = 0x40; // Display '0' _delay_ms(500); PORTD = 0x79; // Display '1' _delay_ms(500); PORTD = 0x24; // Display '2' _delay_ms(500); PORTD = 0x30; // Display '3' _delay_ms(500); PORTD = 0x19; // Display '4' _delay_ms(500); PORTD = 0x12; // Display '5' _delay_ms(500); PORTD = 0x02; // Display '6' _delay_ms(500); PORTD = 0x78; // Display '7' _delay_ms(500); PORTD = 0x00; // Display '8' _delay_ms(500); PORTD = 0x10; // Display '9' _delay_ms(500); // Default 'H' segment turn OFF PORTD = 0xC0; // Display '0' _delay_ms(500); PORTD = 0xF9; // Display '1' _delay_ms(500); PORTD = 0xA4; // Display '2' _delay_ms(500); PORTD = 0xB0; // Display '3' _delay_ms(500); PORTD = 0x99; // Display '4' _delay_ms(500); PORTD = 0x92; // Display '5' _delay_ms(500); PORTD = 0x82; // Display '6' _delay_ms(500); PORTD = 0xF8; // Display '7' _delay_ms(500); PORTD = 0x80; // Display '8' _delay_ms(500); PORTD = 0x90; // Display '9' _delay_ms(500); } }